﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Travel.Web.users
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtuser_name.Text.Trim().Length==0)
			{
				strErr+="用户名不能为空！\\n";	
			}
			if(this.txtpwd.Text.Trim().Length==0)
			{
				strErr+="用户密码不能为空！\\n";	
			}
			if(this.txtname.Text.Trim().Length==0)
			{
				strErr+="姓名不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txttype.Text))
			{
				strErr+="0 普通会员格式错误！\\n";	
			}
			if(this.txtqq.Text.Trim().Length==0)
			{
				strErr+="QQ号不能为空！\\n";	
			}
			if(this.txtemail.Text.Trim().Length==0)
			{
				strErr+="email不能为空！\\n";	
			}
			if(this.txtphone.Text.Trim().Length==0)
			{
				strErr+="手机号码不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtcreated_on.Text))
			{
				strErr+="created_on格式错误！\\n";	
			}
			if(this.txtcreated_by.Text.Trim().Length==0)
			{
				strErr+="创建来源 前台注册为user 不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtchanged_on.Text))
			{
				strErr+="changed_on格式错误！\\n";	
			}
			if(this.txtchanged_by.Text.Trim().Length==0)
			{
				strErr+="changed_by不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string user_name=this.txtuser_name.Text;
			string pwd=this.txtpwd.Text;
			string name=this.txtname.Text;
			int type=int.Parse(this.txttype.Text);
			string qq=this.txtqq.Text;
			string email=this.txtemail.Text;
			string phone=this.txtphone.Text;
			DateTime created_on=DateTime.Parse(this.txtcreated_on.Text);
			string created_by=this.txtcreated_by.Text;
			DateTime changed_on=DateTime.Parse(this.txtchanged_on.Text);
			string changed_by=this.txtchanged_by.Text;

			Travel.Model.users model=new Travel.Model.users();
			model.user_name=user_name;
			model.pwd=pwd;
			model.name=name;
			model.type=type;
			model.qq=qq;
			model.email=email;
			model.phone=phone;
			model.created_on=created_on;
			model.created_by=created_by;
			model.changed_on=changed_on;
			model.changed_by=changed_by;

			Travel.BLL.users bll=new Travel.BLL.users();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
